/*
 * @ProjectName: 编程学习
 * @Copyright:   2019 HangZhou Yi Dev, Ltd. All Right Reserved.
 * @address:     https://yiyuery.github.io/
 * @date:        2019/12/9 8:47 下午
 * @email:       xiazhaoyang@live.com
 * @description: 本内容仅限于编程技术学习使用，转发请注明出处.
 */
package com.example.spring.aop.service.impl;

import com.example.spring.aop.service.IPersonManagerService;
import com.example.spring.aop.service.model.PersonDO;
import com.example.spring.aop.monitor.BusinessLogMonitor;
import lombok.extern.slf4j.Slf4j;

/**
 * <p>
 *
 * </p>
 *
 * @author Yi
 * @version V1.0.0
 * @date 2019/12/9 8:47 下午
 * @modificationHistory=========================逻辑或功能性重大变更记录
 * @modify By: {修改人}  2019/12/9
 * @modify reason: {方法名}:{原因}
 * ...
 */
@Slf4j
public class PersonManagerServiceImpl implements IPersonManagerService {

    @Override
    public void addPerson() {
        BusinessLogMonitor.begin("com.example.spring.aop.service.impl.PersonManagerServiceImpl.addPerson");
        simpleAddPerson();
        BusinessLogMonitor.end();
    }

    @Override
    public void simpleAddPerson() {
        log.info("模拟人员数据添加");
        try {
            Thread.sleep(3000);
        } catch (Exception e) {
            log.error("PersonManagerServiceImpl addPerson failed!");
        }
    }

    @Override
    public void deletePerson() {
        log.info("模拟人员数据删除");
        try {
            Thread.sleep(3000);
        } catch (Exception e) {
            log.error("PersonManagerServiceImpl deletePerson failed!");
        }
    }

    @Override
    public PersonDO modifyPerson(PersonDO personDO) {
        log.info("模拟人员数据修改："+personDO.getName());
        try {
            Thread.sleep(3000);
        } catch (Exception e) {
            log.error("PersonManagerServiceImpl modifyPerson failed!");
        }
        personDO.setName("被修改_"+personDO.getName());
        return personDO;
    }

    @Override
    public void deleteThrowException() {
        log.info("模拟人员数据删除，抛出异常");
        try {
            Thread.sleep(3000);
        } catch (Exception e) {
            log.error("PersonManagerServiceImpl deletePerson failed!");
        }
        throw new IllegalArgumentException("删除失败,抛出异常");
    }

    @Override
    public void simpleAddPersonWithFilter() {
        log.info("模拟人员数据添加");
        try {
            Thread.sleep(3000);
        } catch (Exception e) {
            log.error("PersonManagerServiceImpl addPerson failed!");
        }
    }
}
